<template>
  <el-container>
    <el-header>
      <div class="left-box">
        <el-popconfirm
          title="确认关闭？如果有内容变更，请先保存"
          confirm-button-text="确认"
          cancel-button-text="取消"
          @confirm="$router.push('/page')"
        >
          <template #reference>
            <el-button>x</el-button>
          </template>
        </el-popconfirm>

        <el-input v-model="title" placeholder="请输入文章标题" />
      </div>

      <div class="right-box">
        <el-button type="primary" @click="issue">发布</el-button>
      </div>
    </el-header>

    <el-main>
      <v-md-editor v-model="txt" height="400px"></v-md-editor>
    </el-main>
  </el-container>
</template>

<script>
import { ElMessage } from "element-plus";

export default {
  data() {
    return {
      txt: "",
      ws: null,
      title: "",
    };
  },
  methods: {
    issue() {
      if (this.title === "") {
        ElMessage.warning("请输入文章标题");
        return;
      } else if (this.txt === "") {
        ElMessage.warning("请输入文章内容");
        return;
      } else {
        ElMessage.success("发布成功");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.left-box {
  display: flex;
  align-items: center;
}
</style>
